﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
using SlideIdeaDocument.Format.UIElement.Common;

namespace BoolanElement
{
    public class SerializeCast
    {
        public static string ColorToString(Color color)
        {
            Int32 colour = color.A;
            colour <<= 8;
            colour |= color.R;
            colour <<= 8;
            colour |= color.G; 
            colour <<= 8;
            colour |= color.B;
            return colour.ToString();
        }
        public static Color StringToColor(String color)
        {

            Int32 colour = Convert.ToInt32(color);
            Color ret = Color.FromArgb(colour);
            return ret;
        }

        public static FontStyle StringToFontStyle(String style)
        {
            if (style == "Normal")
            {
                return FontStyle.Regular;
            }
            else if (style == "Italic")
            {
                return FontStyle.Italic;
            }
            else if (style == "Oblique")
            {
                return FontStyle.Bold;
            }
            return FontStyle.Regular;
        }

        public static VerticalAlignment StringToVerticalAlignment(String value)
        {
            if (value == "Top")
                return VerticalAlignment.Top;
            if (value == "Center")
                return VerticalAlignment.Center;
            if (value == "Bottom")
                return VerticalAlignment.Bottom;
            return VerticalAlignment.Center;
        }

        public static HorizontalAlignment StringToUITextAlignment(String value)
        {
            if (value == "Left")
                return HorizontalAlignment.Left;
            if (value == "Center")
                return HorizontalAlignment.Center;
            if (value == "Right")
                return HorizontalAlignment.Right;
            return HorizontalAlignment.Center;
        }

        public static RichTextAlignment StringToTextAlignment(string alignment)
        {
            /* LeftTop = 0,
        CenterTop = 1,
        RightTop = 2,
        LeftCenter = 3,
        CenterCenter = 4,
        RightCenter = 5,
        LeftBottom = 6,
        CenterBottom = 7,
        RightBottom = 8*/

            switch (alignment)
            {
                case "LeftTop": return RichTextAlignment.LeftTop;
                case "CenterTop": return RichTextAlignment.CenterTop;
                case "RightTop": return RichTextAlignment.RightTop;
                case "LeftCenter": return RichTextAlignment.LeftCenter;
                case "CenterCenter": return RichTextAlignment.CenterCenter;
                case "RightCenter": return RichTextAlignment.RightCenter;
                case "LeftBottom": return RichTextAlignment.LeftBottom;
                case "CenterBottom": return RichTextAlignment.CenterBottom;
                case "RightBottom": return RichTextAlignment.RightBottom;
                default: throw new Exception();
            }
 
        }

        public static ShapeStyle StringToTextBoxStyle(string style)
        {
            /* NoBorderNoBKG = 0,
        BorderNoBKG = 1,
        NoBorderBKG=2,
        BorderBKG = 3*/

            switch (style)
            {
                case "NoBorderNoBKG": return ShapeStyle.NoBorderNoBKG;
                case "BorderNoBKG": return ShapeStyle.BorderNoBKG;
                case "NoBorderBKG": return ShapeStyle.NoBorderBKG;
                case "BorderBKG": return ShapeStyle.BorderBKG;
                default: throw new Exception();
            }
        }

    }
}
